<?php

namespace app\user\controller;
use app\common\controller\UserBase;
use app\common\model\Customer as Kehu;
use app\common\model\CustomerTrack;
use app\common\model\CustomerRemind;
use app\common\model\UserConfig;

class Analysis extends UserBase
{
    protected function _initialize()
    {
        parent::_initialize();
        !config('website_status') && die(config('colse_explain'));
        $config = cache('db_config_data');
        if (!$config) {
            $config = [];
            foreach (model('config')->select() as $v) {
                $config[$v['group']][$v['name']] = $v['value'];
            }
            cache('db_config_data', $config);
        }
        config($config);
    }
    
    //参数设置
    public function index()
    {
        //今日时间戳
        $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
        $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
        
        $data['all_customer'] = Kehu::count();
        $data['today_customer'] = Kehu::where("create_time >=".$beginToday." and create_time <=".$endToday."")->count();
        $data['all_track'] = CustomerTrack::count();
        $data['today_track'] = CustomerTrack::where("create_time >=".$beginToday." and create_time <=".$endToday."")->count();
        $data['remind_no'] = CustomerRemind::where(['status'=>'0'])->count();
        $data['remind_yes'] = CustomerRemind::where(['status'=>'1'])->count();
        
        return $this->fetch('index',[
            'data' => $data,
        ]);
    }
    
    
}
